package com.cliff.joinme;

import java.util.ArrayList;
import java.util.Timer;

import com.cliff.joinme.toolkit.ControlPointManager;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;

public class PlayBaseActivity extends SelectRendererActivity {
	protected ArrayList<String> fileList = null;
	protected int currentPos = 0;
	protected boolean havePlayed = false;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		fileList = getIntent().getStringArrayListExtra(
				Constants.EXTRA_NAME_DATALIST);
		currentPos = getIntent().getIntExtra(Constants.EXTRA_NAME_POSITION, 0);
		ControlPointManager.getInstance().startHttpd(fileList);
		havePlayed = false;
	}

	@Override
	protected void onDestroy() {
		ControlPointManager.getInstance().stopHttpd();
		super.onDestroy();
	}

	@Override
	public void onBackPressed() {
		stopAndFinish();
		// super.onBackPressed();
	}

	protected void stopAndFinish() {
		if ((havePlayed)
				&& (null != ControlPointManager.getInstance()
						.getSelectedRenderer()))
			ControlPointManager.getInstance().stopPlaying();
		finish();
	}
}
